<template>
	<view>
			<uni-search-bar placeholder="请输入主播昵称" :focus="true" v-model="searchValue" @input="input">
			</uni-search-bar>
			<view class="nodata" v-if="dataList==''&&searchValue!=''">
				<image src="../../static/暂无内容.png"></image>
			</view>
		<view  v-for="(item,index) in dataList" :key="item.id" class="">
			<s-detail :list="item"></s-detail>
		</view>
		
	</view>
</template>

<script>
	import baseUrl from '@/utils/tools.js'
	import sDetail from '../search/searchDetail.vue'
	export default {
		components:{
			sDetail
		},
		data() {
			return {
				searchValue: '',
				dataList:[]
			}
		},
		methods: {
			//根据昵称搜索
			async search(gjz){
				const res = await this.$api.searchByType({
					currentPage:1,
					pageSize:8,
					nickname:gjz
				})
				console.log(res.data.records)
				res.data.records.forEach(item=>{
					item.avatar = baseUrl.baseUrl+item.avatar
					
				})
				this.dataList=res.data.records
				
			},
			input(res) {
				if(res==''){
					this.dataList=[]
				}else{
					this.search(res)
				}
				
				console.log('----input:', res)
			},
			clear(res) {
				uni.showToast({
					title: 'clear事件，清除值为：' + res.value,
					icon: 'none'
				})
			},

		},
		onBackPress() {
			// #ifdef APP-PLUS
			plus.key.hideSoftKeybord();
			// #endif

		}
	}
</script>

<style scoped>
	.nodata{
		text-align: center;
		margin-top: 150rpx
	}
	image{
		width: 80vw;
	}
</style>
